package com.jml.controller;


import com.jml.service.IMemberService;
import com.jml.service.IMessageService;
import com.jml.util.controller.AbstractBaseController;
import com.jml.vo.Member;
import java.util.List;
import javax.annotation.Resource;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MemberController extends AbstractBaseController {

	@Resource
	private IMessageService messageService;

	@RequestMapping("/addPre")
	public String addPre(){ //增加前的准备操作路径
		return "member_add";
	}

	@RequestMapping("/add")
	@ResponseBody
	public Member add(@Valid  Member vo,BindingResult result){ //
		System.out.println(result.hasErrors());
		List<ObjectError> allErrors = result.getAllErrors();
		for (ObjectError error: allErrors) {
			System.out.println("错误码："+error.getCode()+"  错误信息"+error.getDefaultMessage());
		}
		return vo;
	}

	@RequestMapping("/exception")
	@ResponseBody
	public Member add(){ //
		int i=0;
		int j=10;
		int i1 = j / i;
		return null;
	}


	@RequestMapping("/member_add_pre")
	public String memberAddPre(){ //增加前的准备操作路径
		return "member_add";
	}

	@RequestMapping("/member_add")
	@ResponseBody
	public Member memberAdd(Member member){

		return member;
	}


	@Resource
	private IMemberService iMemberServiceImpl;
	@RequestMapping("/member_get")
	@ResponseBody
	public Member memberGet(String mid){
		return iMemberServiceImpl.get(mid);
	}





}
